package com.yanqu.road.server.cmd.beautyescort;

import com.yanqu.road.pb.beautyescort.BeautyEscortProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.beautyescort.CrossBeautyEscortMgr;
import com.yanqu.road.server.manager.beautyescort.CrossEscortPlayerWrap;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.C_BEAUTY_ESCORT_ROBBED_NOTIFY_BACK, desc = "被劫通知-结果反馈")
public class CrossBeautyEscortRobbedNotifyResultCmd extends CrossCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        BeautyEscortProto.CrossBeautyEscortRobbedNotifyBackMsg reqMsg = BeautyEscortProto.CrossBeautyEscortRobbedNotifyBackMsg.parseFrom(packet.getBytes());
        for (long uid : reqMsg.getReadUserList()) {
            CrossEscortPlayerWrap playerWrap = CrossBeautyEscortMgr.getEscortPlayer(serverId, uid);
            if(playerWrap != null){
                playerWrap.getUserData().setLastReadReportTime(reqMsg.getTime());
                log.info("{} robbed red dot sync to {}", reqMsg.getRobbedUserId(), uid);
            }
        }
    }

    @Override
    public void sendData() {

    }
}
